package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysZxContent;
import com.ruoyi.system.service.ISysZxContentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资讯内容维护Controller
 * 
 * @author ruoyi
 * @date 2024-04-03
 */
@RestController
@RequestMapping("/system/zxcontent")
public class SysZxContentController extends BaseController
{
    @Autowired
    private ISysZxContentService sysZxContentService;

    /**
     * 查询资讯内容维护列表
     */
    @PreAuthorize("@ss.hasPermi('system:zxcontent:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysZxContent sysZxContent)
    {
        startPage();
        List<SysZxContent> list = sysZxContentService.selectSysZxContentList(sysZxContent);
        return getDataTable(list);
    }

    /**
     * 导出资讯内容维护列表
     */
    @PreAuthorize("@ss.hasPermi('system:zxcontent:export')")
    @Log(title = "资讯内容维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysZxContent sysZxContent)
    {
        List<SysZxContent> list = sysZxContentService.selectSysZxContentList(sysZxContent);
        ExcelUtil<SysZxContent> util = new ExcelUtil<SysZxContent>(SysZxContent.class);
        util.exportExcel(response, list, "资讯内容维护数据");
    }

    /**
     * 获取资讯内容维护详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:zxcontent:query')")
    @GetMapping(value = "/{contentid}")
    public AjaxResult getInfo(@PathVariable("contentid") Long contentid)
    {
        return success(sysZxContentService.selectSysZxContentByContentid(contentid));
    }

    /**
     * 新增资讯内容维护
     */
    @PreAuthorize("@ss.hasPermi('system:zxcontent:add')")
    @Log(title = "资讯内容维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysZxContent sysZxContent)
    {
        return toAjax(sysZxContentService.insertSysZxContent(sysZxContent));
    }

    /**
     * 修改资讯内容维护
     */
    @PreAuthorize("@ss.hasPermi('system:zxcontent:edit')")
    @Log(title = "资讯内容维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysZxContent sysZxContent)
    {
        return toAjax(sysZxContentService.updateSysZxContent(sysZxContent));
    }

    /**
     * 删除资讯内容维护
     */
    @PreAuthorize("@ss.hasPermi('system:zxcontent:remove')")
    @Log(title = "资讯内容维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contentids}")
    public AjaxResult remove(@PathVariable Long[] contentids)
    {
        return toAjax(sysZxContentService.deleteSysZxContentByContentids(contentids));
    }
}
